# -*- coding: utf-8 -*-
# @Author: QX
# @File: day7_0073tuan.py
from time import sleep

from  appium   import webdriver
from appium.webdriver.common.appiumby import AppiumBy
from appium.webdriver.common.touch_action import TouchAction

dic = {
  "platformName": "Android",
  "appium:platformVersion": "9",
  "appium:appPackage": "com.android.settings",
  "appium:appActivity": ".Settings",
  "appium:deviceName": "emulator-5554",
  "appium:automationName": "UIAutomator2"
}
driver = webdriver.Remote('http://127.0.0.1:4723',dic)
driver.implicitly_wait(10)

driver.find_element(AppiumBy.XPATH,'//*[@text="安全性和位置信息"]').click()
driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR,'new UiSelector().text("屏幕锁定")').click()
driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR,'new UiSelector().text("图案")').click()
sleep(3)
action = TouchAction(driver)
(action.press(x=230,y=730).move_to(x=451,y=730)\
 .move_to(x=451,y=950).move_to(x=451,y=1171).\
 move_to(x=668,y=1171).release())
action.perform()
sleep(2)
driver.press_keycode(3)